<?php
use yii\helpers\Html;
use yii\helpers\Url;
use app\lib\WeixinUtils;

/* @var $this yii\web\View */
/* @var $content string 字符串 */


$web = Url::to("@web");
//var_dump($goods);
//var_dump($IMG_INFO)
//;exit;
?>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>收货信息</title>
    <link type="text/css" href="<?= $web ?>/css/bag/collect-goods-message.css" rel="stylesheet"/>
    <link type="text/css" href="<?= $web ?>/css/bag/collect-goods-message_style.css" rel="stylesheet"/>
    <link type="text/css" href="<?= $web ?>/css/bag/global.css" rel="stylesheet"/>
    <link type="text/css" href="<?= $web ?>/css/bag/weui.css" rel="stylesheet"/>
    <style type="text/css">
        div.flicking_con a {
            background: url('<?=$web?>/img/bag/goods_detail_image/btn_main_img.png') 0 0 no-repeat;
            background-size: 100%;
        }
    </style>
    <script type="text/javascript" src="<?= $web ?>/js/jquery.js"></script>
    <script type="text/javascript" src="<?= $web ?>/js/tools.js"></script>
    <script type="text/javascript" src="<?= $web ?>/js/bag/jquery.event.drag-1.5.min.js"></script>
    <script type="text/javascript" src="<?= $web ?>/js/bag/jquery.touchSlider.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".main_visual").hover(function () {
                $("#btn_prev,#btn_next").fadeIn()
            }, function () {
                $("#btn_prev,#btn_next").fadeOut()
            });

            $dragBln = false;

            $(".main_image").touchSlider({
                flexible: true,
                speed: 200,//如果是一张图片，改成0
                btn_prev: $("#btn_prev"),
                btn_next: $("#btn_next"),
                paging: $(".flicking_con a"),
                counter: function (e) {
                    $(".flicking_con a").removeClass("on").eq(e.current - 1).addClass("on");
                }
            });

            $(".main_image").bind("mousedown", function () {
                $dragBln = false;
            });

            $(".main_image").bind("dragstart", function () {
                $dragBln = true;
            });

            $(".main_image a").click(function () {
                if ($dragBln) {
                    return false;
                }
            });

            timer = setInterval(function () {
                $("#btn_next").click();
            }, 5000);

            $(".main_visual").hover(function () {
                clearInterval(timer);
            }, function () {
                timer = setInterval(function () {
                    $("#btn_next").click();
                }, 5000);
            });

            $(".main_image").bind("touchstart", function () {
                clearInterval(timer);
            }).bind("touchend", function () {
                timer = setInterval(function () {
                    $("#btn_next").click();
                }, 5000);
            });


        });
        $(function() {
            // 任何需要执行的js特效
            var w = $(document).width();
            if (w > 640) {
                w = 640;
            }
            $("body").css("font-size", w * 20 / 320);
        });

        function getAreaOther(pk){
            var data={};
            data.pk=pk;
            var re=returnjson("<?=Url::to(["wx-biz/get-area-handle"])?>",data);
            if(re.flag==1){
                return re.others;
            }else{
                alert(re.msg);
                return false;
            }
        }
        $(function($){
            //init
            var address=<?=$address ? json_encode($address) : 0?>;

            if(address!=0){
                $('#txt_name').val(address.NAME);
                $('#txt_phone').val(address.PHONE);
                $('#txt_sheng').val(address.PROVINCE);
                $('#txt_shi').val(address.CITY);
                $('#txt_xian').val(address.REGION);
                $('#txt_address').val(address.ADDRESS);
            }

            var isExe=false;
            $("#btn_exec").click(function(){
                if(isExe){
                    return;
                }
                isExe=true;
                var data={};
                data.code_id="<?=$goods['CODE_ID']?>";
                data.CREMARK="";
                data.RECEIVERNAME=$('#txt_name').val();
                data.RECEIVERPHONE=$('#txt_phone').val();
                data.RECEIVERADDRESS=   $('#txt_address').val();
                data.sheng= $('#txt_sheng').val();
                data.shi= $('#txt_shi').val();
                data.qu=$('#txt_xian').val();
                //校验

                if(data.sheng._trim()==''){
                    alert("省必须填写!");
                    return;
                }
                if(data.shi._trim()==''){
                    alert("市必须填写!");
                    return;
                }
                if(data.qu._trim()==''){
                    alert("区/县必须填写!");
                    return;
                }
                if(data.RECEIVERNAME._trim()==''){
                    alert("我的姓名必须填写!");
                    return;
                }
                if(data.RECEIVERPHONE._trim()==''){
                    alert("手机号码必须填写!");
                    return;
                }else{
                    if(checkMobile(data.RECEIVERPHONE._trim())==false){
                        alert("请填写正确手机号!");
                        return;
                    }
                }
                if(data.RECEIVERADDRESS._trim()==''){
                    alert("详细地址必须填写!");
                    return;
                }

                //下订单
                var re=returnjson("<?=Url::to(["wx-bag/submit-order-handle"])?>",data);
//                alert(JSON.stringify(re) );
//                return;
                if(re.flag==1){
                    alert("兑换成功");
                    window.location.href="<?=Url::to(["wx-biz/good-submit-order-success"]);?>";

                    return;
                }else{
                    alert(re.msg);
                    isExe=false;
                };
            });
        });
        //兑换朵拉币
        function exchange_coin(){
            if(confirm('您想把此礼品兑换成{0}个朵拉币吗?'._format(<?=$goods["PRICE_G"]?>))){
                var data={};
                data.type_id=2;
                data.order_id="<?=$code?>";
                data.exchange_id="<?=$goods['CODE_ID']?>";

                var re=returnjson("<?=Url::to(["wx-home/receive-dora-coin-handle"])?>",data);
                if(re.flag==1){
                    alert('兑换成功!');
                    window.location.href = "<?=Url::to(["wx-bag/view-gift-nav"]);?>?code_id=" + "<?=$goods['CODE_ID']?>";
                }else{
                    alert(re.msg);
                    return false;
                }
            }
        }
        href_addressManage=function(){
            window.location.href='<?=Url::to(['wx-home/address-management','backurl'=>Yii::$app->request->absoluteUrl])?>';
        };
    </script>
</head>
<body>

<div class="main">
    <div class="carousel" style="display:none;">
        <div class="kePublic">
            <div class="main_visual">
                <div class="flicking_con">
                    <?php

                        foreach($IMG_INFO as &$img){
                            echo ' <a href="#"></a>';
                        }
                    ?>
                  <!--  <a href="#">1</a>
                    <a href="#">2</a>
                    <a href="#">3</a>
                    <a href="#">4</a>
                    <a href="#">5</a>-->
                </div>
                <div class="main_image">
                    <ul>
                        <?php
                        foreach($IMG_INFO as &$img){
                            $t=$img['GOODS_EXHI_URL'];
                            echo "<li><div style='background-image:url($t);'></div></li>";
                        }
                        ?>
                       <!-- <li>
                            <div style="background-image:url(<?/*= $web */?>/img/bag/goods_detail_image/s.png);"></div>
                        </li>
                        <li>
                            <div style="background-image:url(<?/*= $web */?>/img/bag/goods_detail_image/s.png);"></div>
                        </li>
                        <li>
                            <div style="background-image:url(<?/*= $web */?>/img/bag/goods_detail_image/s.png);"></div>
                        </li>
                        <li>
                            <div style="background-image:url(<?/*= $web */?>/img/bag/goods_detail_image/s.png);"></div>
                        </li>
                        <li>
                            <div style="background-image:url(<?/*= $web */?>/img/bag/goods_detail_image/s.png);"></div>
                        </li>-->
                    </ul>
                    <a href="javascript:;" id="btn_prev"></a>
                    <a href="javascript:;" id="btn_next"></a>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div class="hr"></div>
    <div class="title">
        <div class="title_title"><?=$goods['GOODS_NAME']?></div>
        <div class="title_message">本网站所售产品均为厂商正品，如有任何问题可与我们客服人员联系，我们会在第一时间跟您沟通处理。</div>
    </div>
    <div class="address" onclick="href_addressManage()">
        <div class="electric">
            <input class="input_name" type="text"  readonly="readonly" placeholder="我的姓名" id="txt_name"/>
        </div>
        <div class="electric">
            <input class="input_phone" type="text"  readonly="readonly" placeholder="我的手机" id="txt_phone"/>
        </div>
        <div class="electric">
            <input class="input_name" type="text" readonly="readonly" placeholder="省" id="txt_sheng"/>
        </div>
        <div class="electric">
            <input class="input_name" type="text" readonly="readonly" placeholder="市" id="txt_shi"/>
        </div>
        <div class="electric">
            <input class="input_name" type="text"  readonly="readonly"placeholder="区/县" id="txt_xian"/>
        </div>
        <div class="electrics">
            <input class="input_address" type="text"  readonly="readonly"placeholder="详细地址" id="txt_address"/>
        </div>
    </div>
    <div class="but" id="btn_exec">确认兑换</div>
    <div class="down">
        确认兑换后，工作人员会在3-5个工作日安排发送礼品，请耐心等候
        <br/><br/>
        不喜欢？ <label style="color: rgb(225,67,66);" onclick="exchange_coin()">换成朵拉币，</label> 挑选更多礼物
    </div>
</div>

</body>
</html>
